<template>
	<div class="container">
		<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="140px">
			<el-tabs v-model="activeName" @tab-click="handleClick">
				<el-tab-pane label="企业介绍" name="企业介绍">
					<h3>企业介绍</h3>
					<el-row>
						<el-col :span="12">
							<el-form-item label="联系人：">
								<el-input placeholder="请输入内容" v-model="ruleForm.liaisonName" style="width:300px">
								</el-input>
							</el-form-item>
						</el-col>
						<el-col :span="11">
							<el-form-item label="联系电话：">
								<el-input placeholder="请输入内容" v-model="ruleForm.phone" style="width:300px">
								</el-input>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="22">
							<el-form-item label="企业介绍：">
								<div ref="editor" style="width:100%;"></div>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row>
						<el-col :span="7">
							<el-form-item label="封面和图片：">
								<el-upload class="upload-poster" action="https://jsonplaceholder.typicode.com/posts/"
									:show-file-list="false" :on-change="imgPreview" :auto-upload="false">
									<img v-if="coverImg" :src="coverImg" class="avatar">
									<i v-else class="el-icon-plus avatar-uploader-icon"></i>
								</el-upload>
								jpg、png、gif格式，不超过2MB
							</el-form-item>
						</el-col>
						<el-col :span="10">
							<el-form-item label="" label-width="0">
								<textarea name="" id="" cols="100" style="margin-left:3px;" rows="10"
									v-model="ruleForm.remark"> </textarea>
							</el-form-item>
						</el-col>
					</el-row>
				</el-tab-pane>
				<el-tab-pane label="证件证书" name="证件证书">
					<h3>证件证书</h3>
					<el-form-item label="企业资质证书：" style="margin-top:20px;">
						<el-button @click="addedlicense">添加</el-button>
					</el-form-item>
					<el-form-item label="" style="width:450px;">
						<div v-for="(item, index) in ruleForm.materialList" :key="index"
							style="border-radius:4px; border:1px solid #dcdfe6;padding:10px;position:relative;height:110px;margin-bottom:10px;">
							<div style="width:100px;height:100px;border:1px solid #dcdfe6;border-radius:4px;"
								@click="checklist(item, index)">
								<img :src="item.materialImg1"
									v-if="item.materialImg1 != '' && item.materialImg1 != undefined" alt=""
									style="width:100px;height:100px;border:1px solid #dcdfe6;">
								<img :src="$store.state.plantImg + item.materialImg" v-else alt=""
									style="width:100px;height:100px;border:1px solid #dcdfe6;">
							</div>
							<div style="position:absolute; top:2px; right:10px;cursor:pointer;" @click="deletelist(index)">x
							</div>
							<div style="position:absolute;top:30px;left:120px;width:150px;overflow:hidden;white-space:nowrap;"
								@click="checklist(item, index)">
								<div>{{ item.name }}</div>
								<div style="color:#c0c4cc;">{{ item.deadline }}</div>
							</div>
						</div>
					</el-form-item>
				</el-tab-pane>
				<el-tab-pane label="基本信息" name="基本信息">
					<div>
						<div class="container">
							<h3>企业信息</h3>
							<el-row :gutter="20" style="margin-top:20px;">
								<el-col :span="10">
									<el-form-item label="企业简称">
										<el-input class="handle-input" placeholder="追溯码上展示，不得超过6个字"
											v-model="ruleForm.abbreviation" style="width:300px"></el-input>
									</el-form-item>
									<!-- <el-form-item label="所在区域：" prop="area">
					        				<el-cascader size="large" :options="options" style="width:300px" v-model="form.area" ></el-cascader>
					        			</el-form-item> -->


									<el-form-item label="营业执照照片">
										<el-upload class="upload-poster"
											action="https://jsonplaceholder.typicode.com/posts/" :show-file-list="false"
											:on-change="imgPreview3" :auto-upload="false">
											<img v-if="licenseImg1" :src="licenseImg1" class="avatar">
											<i v-else class="el-icon-plus avatar-uploader-icon"></i>
										</el-upload>
										jpg、png、gif格式，不超过2MB
									</el-form-item>
								</el-col>
								<el-col :span="12">
									<el-form-item label="企业名称">
										<el-input class="handle-input" placeholder="企业全称" v-model="ruleForm.name"
											style="width:300px"></el-input>
									</el-form-item>

									<el-form-item label="统一社会信用代码">
										<el-input class="handle-input" placeholder="请输入统一社会信用代码"
											v-model="ruleForm.creditCode" style="width:300px"></el-input>
									</el-form-item>
									<el-form-item label="注册地址">
										<el-input class="handle-input" placeholder="请填写详细注册地址" v-model="ruleForm.address"
											style="width:300px"></el-input>
									</el-form-item>

									<el-form-item label="营业期限：">
										<el-date-picker value-format="yyyy/MM/dd" format="yyyy/MM/dd" style="width:300px"
											v-model="value1" type="daterange" :disabled="disabled1" range-separator="至"
											start-placeholder="开始日期" end-placeholder="结束日期">
										</el-date-picker>
										<el-checkbox style="margin-left:10px;" v-model="checked1"
											@change="changeState1">长期</el-checkbox>
									</el-form-item>
									<el-form-item label="物联网平台名称">
										<el-input class="handle-input" placeholder="请填写物联网平台名称" v-model="wuName" @blur="saveName"
											style="width:300px"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</div>
						<div class="container" style="margin-top:20px">
							<h3 style="margin-bottom: 20px">法人信息</h3>
							<el-row class="demo-ruleForm">
								<el-col :span="10">
									<el-form-item label="身份证照片：（人像面）" label-width="100px" style="margin-left:35px;">
										<upload-img ref="uploadChang1" :maxNum="1" :files='listUrl1'
											style="width:300px"></upload-img>
									</el-form-item>
									<el-form-item label="身份证照片：（国徽面）" label-width="100px" style="margin-left:35px;">
										<upload-img ref="uploadChang2" :maxNum="1" :files='listUrl2'
											style="width:300px"></upload-img>
									</el-form-item>
								</el-col>
								<el-col :span="14">
									<el-form-item label="法人代表：">
										<el-input v-model="ruleForm.legalName" style="width:300px"></el-input>
									</el-form-item>
									<el-form-item label="身份证号：">
										<el-input v-model="ruleForm.legalID" style="width:300px"></el-input>
									</el-form-item>

									<el-form-item label="营业期限：">
										<el-date-picker value-format="yyyy/MM/dd" format="yyyy/MM/dd" style="width:300px"
											v-model="value5" type="daterange" :disabled="disabled5" range-separator="至"
											start-placeholder="开始日期" end-placeholder="结束日期">
										</el-date-picker>
										<el-checkbox style="margin-left:10px;" v-model="checked5"
											@change="changeState5">长期</el-checkbox>
									</el-form-item>
									<el-form-item label="手机号：" style="width:500px">
										<el-input v-model="ruleForm.legalPhone" style="width:300px"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</div>

						<div class="container" style="margin-top:20px">
							<h3 style="margin-bottom: 20px">运营者信息</h3>
							<el-row class="demo-ruleForm">
								<el-col :span="10">
									<el-form-item label="身份证照片：（人像面）" label-width="100px" style="margin-left:35px;">
										<upload-img ref="uploadChang3" :maxNum="1" :files='listUrl3'
											style="width:300px"></upload-img>
									</el-form-item>
									<el-form-item label="身份证照片：（国徽面）" label-width="100px" style="margin-left:35px;">
										<upload-img ref="uploadChang4" :maxNum="1" :files='listUrl4'
											style="width:300px"></upload-img>
									</el-form-item>
								</el-col>
								<el-col :span="14">

									<el-form-item label="运营人代表：">
										<el-input v-model="ruleForm.operateName" style="width:300px"></el-input>
									</el-form-item>
									<el-form-item label="身份证号：">
										<el-input v-model="ruleForm.operateID" style="width:300px"></el-input>
									</el-form-item>
									<el-form-item label="营业期限：">
										<el-date-picker value-format="yyyy/MM/dd" format="yyyy/MM/dd" style="width:300px"
											v-model="value3" type="daterange" :disabled="disabled3" range-separator="至"
											start-placeholder="开始日期" end-placeholder="结束日期">
										</el-date-picker>
										<el-checkbox style="margin-left:10px;" v-model="checked3"
											@change="changeState3">长期</el-checkbox>
									</el-form-item>
									<el-form-item label="手机号：" style="width:500px">
										<el-input v-model="ruleForm.operatePhone" style="width:300px"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</div>
					</div>
				</el-tab-pane>
				<!-- 企业秀 -->
				<el-tab-pane label="企业秀" name="企业秀">
					<div style="height:800px;">
						<keep-alive v-if="isRouterAlive">
							<htmlsrs></htmlsrs>
						</keep-alive>


					</div>

				</el-tab-pane>

				<el-tab-pane label="软件LOGO" name="软件LOGO">
					<h3>软件LOGO</h3>
					<el-form-item label="长方形">
						<el-upload class="upload-poster" action="https://jsonplaceholder.typicode.com/posts/"
							:show-file-list="false" :on-change="imgPreview6" :auto-upload="false">
							<img v-if="logoImg" :src="logoImg" class="avatar">
							<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						</el-upload>
						支持透明背景png格式，建议尺寸长宽5:1，不得超过2M
					</el-form-item>

					<el-form-item label="正方形">
						<el-upload class="upload-poster" action="https://jsonplaceholder.typicode.com/posts/"
							:show-file-list="false" :on-change="imgPreview7" :auto-upload="false">
							<img v-if="logozImg" :src="logozImg" class="avatar">
							<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						</el-upload>
						支持透明背景png格式，建议尺寸长宽1:1，不得超过2M
					</el-form-item>
				</el-tab-pane>
			</el-tabs>
			<el-dialog title="企业资质证书" :visible.sync="xslicense" width="800px">
				<el-form style="margin-left:30px;" label-width="120px">
					<el-form-item label="证书图片：">
						<el-upload class="upload-poster" action="https://jsonplaceholder.typicode.com/posts/"
							:show-file-list="false" :on-change="uploading" :auto-upload="false">
							<img v-if="materialImg1" :src="materialImg1" class="avatar">
							<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						</el-upload>
						jpg、png、gif格式，不超过2MB
					</el-form-item>
					<el-form-item label="证书名称：">
						<el-input v-model="zsname" placeholder="请输入" autocomplete="off" style="width:300px;"></el-input>
					</el-form-item>
					<el-form-item label="营业期限：">
						<el-date-picker value-format="yyyy/MM/dd" format="yyyy/MM/dd" style="width:300px" v-model="value"
							type="daterange" :disabled="disabled" range-separator="至" start-placeholder="开始日期"
							end-placeholder="结束日期">
						</el-date-picker>
						<el-checkbox style="margin-left:10px;" v-model="checked" @change="changeState">长期</el-checkbox>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button @click="xslicense = false">取 消</el-button>
					<el-button type="primary" @click="close">确 定</el-button>
				</div>
			</el-dialog>
			<el-form-item class="footerFixed" label-width="0px">
				<el-button v-if="!added" v-show="show" type="primary" @click="submitRules('ruleForm')">提交</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
import uploadImg from '../../../common/uploadImg';
import htmlsrs from "./htmlsrs.vue"

import QRCode from 'qrcodejs2';
import { company_findById, company_update, conpanyshow_load, conpanyshow_update, saveName } from "@/request/api";
import E from 'wangeditor';
export default {
	inject: ['reload'],
	components: {
		uploadImg,
		htmlsrs
	},
	provide: function () {
		return {
			reload: this.reload
		}
	},
	data() {
		return {
			wuName: '',
			isRouterAlive: true,
			urllink: '',
			logozImg: '',
			logoImg: '',
			listUrl1: '',
			listUrl2: '',
			listUrl3: '',
			listUrl4: '',
			form: {},
			files3: '',
			licenseImg1: '',
			checked3: "",
			disabled3: false,
			value3: '',
			addeddialog2: false,
			zsname: '',
			files: '',
			coverImg: '',
			deadline: '',
			materialImg1: '',
			materialImg: '',
			value: '',
			disabled: false,
			checked: '',
			value5: '',
			value1: '',
			disabled1: false,
			checked1: '',
			disabled5: false,
			checked5: '',
			xslicense: false,
			activeName: "企业介绍",
			materials: [
				{
					name: 'sad',
					deadline: '',
					materialImg: ''
				}
			],
			ruleForm: {
				// 企业介绍
				liaisonName: '',
				phone: '',
				introduce: '',
				coverImg: '',
				remark: '',
				// 企业证书
				materials: '',
				materialList: []
			},
			index: '',
			rules: {},
			user: {},
			added: true,
			show: true,
			htmlurl: ''
		}
	},
	created() {

	},
	mounted() {
		this.init()
		this.judgmentAuthority()
		this.getcompanyshow()

		let ids = localStorage.getItem("companyId")
		this.urllink = "http://39.96.59.234:8884/scan/company.html?code=" + ids
		// this.creatQrCode()
		var editor = new E(this.$refs.editor)
		editor.customConfig.debug = true
		editor.customConfig.uploadImgServer = this.$store.state.uploadImgurl + '/file/upload';
		editor.customConfig.uploadFileName = 'files';
		editor.customConfig.uploadImgHooks = {
			customInsert: function (insertImg, result, editor) {

				var url = "https://bbgy.cpzsyun.com:82/api/plant/file/show/" + result.data.fileName
				insertImg(url)

			}
		}
		editor.customConfig.onchange = (html) => {
			this.ruleForm.introduce = html
		}
		editor.create();
		editor.txt.html(this.ruleForm.introduce)
	},
	methods: {
		saveName(){
			saveName().then(res => {
				console.log(res);
				// this.wuName = res.data.iotName
			})
		},
		reload() {
			this.isRouterAlive = false
			this.$nextTick(function () {
				this.isRouterAlive = true
			})
		},
		submitchange() {
			let id = localStorage.getItem("companyId")
			this.showcompanyres.companyId = id
			this.showcompanyres.code = id
			let data = this.showcompanyres
			conpanyshow_update(data).then((res) => {
				this.getcompanyshow()
				this.reload()
			})
		},


		getcompanyshow() {
			let id = localStorage.getItem("companyId")
			conpanyshow_load(id).then((res) => {
				this.showcompanyres = res.data

			})
		},
		changeState1() {
			if (this.checked1 == false) {
				this.disabled1 = false
			} else {
				this.disabled1 = true
				this.value1 = ""
			}
		},
		imgPreview3(file, fileList) {
			this.licenseImg1 = URL.createObjectURL(file.raw);
			let fileName = file.name;
			let regex = /(.jpg|.gif|.png|.jpeg)$/;
			if (regex.test(fileName.toLowerCase())) {
				this.ruleForm.files1 = file.raw
				this.ruleForm.licenseImg = file.name
			} else {
				this.$message.error('请选择图片文件');
			}
		},
		imgPreview6(file, fileList) {
			this.logoImg = URL.createObjectURL(file.raw);
			let fileName = file.name;
			let regex = /(.jpg|.gif|.png|.jpeg)$/;
			if (regex.test(fileName.toLowerCase())) {
				this.ruleForm.files2 = file.raw
				this.ruleForm.logoImg = file.name
			} else {
				this.$message.error('请选择图片文件');
			}
		},
		imgPreview7(file, fileList) {
			this.logozImg = URL.createObjectURL(file.raw);
			let fileName = file.name;
			let regex = /(.jpg|.gif|.png|.jpeg)$/;
			if (regex.test(fileName.toLowerCase())) {
				this.ruleForm.files3 = file.raw
				this.ruleForm.logozImg = file.name
			} else {
				this.$message.error('请选择图片文件');
			}
		},
		addlower2() {
			this.addeddialog2 = false
		},
		certificate2() {
			this.addeddialog2 = true
		},
		uploading(file, fileList) {
			this.materialImg1 = URL.createObjectURL(file.raw);
			let fileName = file.name;
			let regex = /(.jpg|.gif|.png|.jpeg)$/;
			if (regex.test(fileName.toLowerCase())) {
				this.files = file.raw
				this.materialImg = file.name
			} else {
				this.$message.error('请选择图片文件');
			}
		},
		deletelist(index) {
			this.index = index
			this.ruleForm.materialList.splice(index, 1)
		},
		checklist(item, index) {
			// console.log(item,index)
			this.xslicense = true
			this.materialImg1 = this.$store.state.plantImg + item.materialImg
			this.zsname = item.name
			if (item.deadline != "永久") {
				var srr = item.deadline.split("至")
				this.value = srr
				this.disabled = false
			} else {
				this.value7 = ""
				this.checked = true
				this.disabled = true
			}
		},
		addedlicense() {
			this.zsname = ""
			this.materialImg1 = ""
			this.value = ""
			this.xslicense = true

		},
		close() {

			if (this.zsname == "") {
				this.$notify({
					title: '提示',
					message: '证书名不能为空',
					type: 'info'
				});
				return false
			}
			if (this.materialImg == "") {
				this.$notify({
					title: '提示',
					message: '证书图片不能为空',
					type: 'info'
				});
				return false
			}

			// }else{
			if (this.checked == true) {
				this.deadline = "永久"
			} else {
				if (this.value == "") {

				} else {
					this.deadline = this.value[0] + "至" + this.value[1]
				}
			}
			// }
			this.xslicense = false
			this.ruleForm.materialList.push({
				materialImg1: this.materialImg1,
				name: this.zsname,
				materialImg: this.materialImg,
				deadline: this.deadline,
				files: this.files
			})
			// console.log(this.materialList)
		},
		changeState() {
			if (this.checked == false) {
				this.disabled = false
			} else {
				this.disabled = true
				this.value = ""
			}
		},
		changeState5() {
			if (this.checked5 == false) {
				this.disabled5 = false
			} else {
				this.disabled5 = true
				this.value5 = ""
			}
		},
		getindex(index) {
			console.log(index)
		},
		handleClick() {
			if (this.activeName == "企业秀") {
				this.show = false
			} else {
				this.show = true
			}
		},
		addlicense() {
			this.materials.push({
				name: '',
				deadline: '',
				materialImg: ''
			})
		},
		init() {

			var id = localStorage.getItem("companyId")

			company_findById(id).then((res) => {
				this.ruleForm = res.data
				this.user = res.data.us

				if (this.ruleForm.trem != "") {
					if (this.ruleForm.term != "永久") {
						var srr = res.data.term.split("至")
						this.value1 = srr
						this.disabled1 = false
					} else {
						this.value1 = ""
						this.checked1 = true
						this.disabled1 = true
					}
				}
				if (this.ruleForm.legalTime != "") {
					if (this.ruleForm.legalTime != "永久") {
						var srr = res.data.legalTime.split("至")
						this.value5 = srr
						this.disabled5 = false
					} else {
						this.value5 = ""
						this.checked5 = true
						this.disabled5 = true
					}
				}
				if (this.ruleForm.operateTime != "") {
					if (this.ruleForm.operateTime != "永久") {
						var srr = res.data.operateTime.split("至")
						this.value3 = srr
						this.disabled3 = false
					} else {
						this.value3 = ""
						this.checked3 = true
						this.disabled3 = true
					}
				}

				// this.ruleForm.oldLegalImg = res.data.legalImg
				const arr1 = this.ruleForm.legalImg.split(";")
				if (arr1 == "") {

				} else {
					this.listUrl1 = arr1.map(t => {
						var obj = {}
						obj.url = this.$store.state.plantImg + t
						obj.name = this.$store.state.plantImg + t
						return obj
					})
				}

				//法人信息  身份背面
				// this.ruleForm.oldLegalIDImg = res.data.legalIDImg
				const arr2 = this.ruleForm.legalIDImg.split(";")
				if (arr2 == "") {

				} else {
					this.listUrl2 = arr2.map(t => {
						var obj = {}
						obj.url = this.$store.state.plantImg + t
						obj.name = this.$store.state.plantImg + t
						return obj
					})
				}

				// this.ruleForm.oldLegalIDImg = res.data.legalIDImg
				const arr3 = this.ruleForm.operateImg.split(";")
				if (arr3 == "") {

				} else {
					this.listUrl3 = arr2.map(t => {
						var obj = {}
						obj.url = this.$store.state.plantImg + t
						obj.name = this.$store.state.plantImg + t
						return obj
					})
				}

				// this.ruleForm.oldLegalIDImg = res.data.legalIDImg
				const arr4 = this.ruleForm.operateIDImg.split(";")
				if (arr4 == "") {

				} else {
					this.listUrl4 = arr4.map(t => {
						var obj = {}
						obj.url = this.$store.state.plantImg + t
						obj.name = this.$store.state.plantImg + t
						return obj
					})
				}
				if (this.ruleForm.logoImg == "" || this.ruleForm.logoImg == null) {
					this.ruleForm.logoImg = this.ruleForm.logoImg
				} else {
					this.logoImg = this.$store.state.plantImg + this.ruleForm.logoImg
				}
				if (this.ruleForm.logozImg == "" || this.ruleForm.logozImg == null) {
					this.ruleForm.logozImg = this.ruleForm.logozImg
				} else {
					this.logozImg = this.$store.state.plantImg + this.ruleForm.logozImg
				}
				if (this.ruleForm.licenseImg == "" || this.ruleForm.licenseImg == null) {
					this.ruleForm.licenseImg = this.ruleForm.licenseImg
				} else {
					this.licenseImg1 = this.$store.state.plantImg + this.ruleForm.licenseImg
				}
				if (this.ruleForm.coverImg == "" || this.ruleForm.coverImg == null) {
					this.ruleForm.coverImg = this.ruleForm.coverImg
				} else {
					this.coverImg = this.$store.state.plantImg + this.ruleForm.coverImg
				}

				if (this.ruleForm.introduce == undefined || this.ruleForm.introduce == null || this.ruleForm.introduce == "") {

				} else {
					var editor = new E(this.$refs.editor)
					editor.customConfig.uploadImgServer = this.$store.state.uploadImgurl + '/file/upload';
					editor.customConfig.uploadFileName = 'file';
					editor.customConfig.uploadImgHooks = {
						customInsert: function (insertImg, result, editor) {

							var url = "https://bbgy.cpzsyun.com:82/api/plant/file/show/" + result.data.fileName
							insertImg(url)
						}
					}
					editor.customConfig.onchange = (html) => {
						this.ruleForm.introduce = html
					}
					editor.create();
					editor.txt.html(this.ruleForm.introduce)
				}

			})
		},
		changeState3() {
			if (this.checked3 = false) {
				this.disabled3 = false
			} else {
				this.disabled3 = true
				this.value3 = ""
			}
		},
		imgPreview(file, fileList) {
			this.coverImg = URL.createObjectURL(file.raw);
			let fileName = file.name;
			let regex = /(.jpg|.gif|.png|.jpeg)$/;
			if (regex.test(fileName.toLowerCase())) {
				this.ruleForm.files = file.raw
				this.ruleForm.coverImg = file.name
			} else {
				this.$message.error('请选择图片文件');
			}
		},
		submitRules() {
			let data = this.ruleForm
			let formdata = new FormData()
			if (this.checked1 == true) {
				this.ruleForm.term = "永久"
			} else {
				if (this.value1 == "") {

				} else {
					this.ruleForm.term = this.value1[0] + "至" + this.value1[1]
				}
			}

			if (this.checked5 == true) {
				this.ruleForm.legalTime = "永久"
			} else {
				if (this.value5 == "") {

				} else {
					this.ruleForm.legalTime = this.value5[0] + "至" + this.value5[1]
				}
			}

			if (this.checked3 == true) {
				this.ruleForm.operateTime = "永久"
			} else {
				if (this.value3 == "") {

				} else {
					this.ruleForm.operateTime = this.value3[0] + "至" + this.value3[1]
				}
			}

			var imgurls1 = this.$refs.uploadChang1.fileList
			var arr1 = ""
			for (var i = 0; i < imgurls1.length; i++) {
				if (imgurls1[i].status != "success") {
					formdata.append("files", imgurls1[i].raw)
				}
				arr1 += imgurls1[i].name + ';'
			}
			var str1 = arr1.substr(0, arr1.length - 1)
			this.ruleForm.legalImg = str1.substring(str1.lastIndexOf("/") + 1)

			var imgurls2 = this.$refs.uploadChang2.fileList
			var arr2 = ""
			for (var i = 0; i < imgurls2.length; i++) {
				if (imgurls2[i].status != "success") {
					formdata.append("files", imgurls2[i].raw)
				}
				arr2 += imgurls2[i].name + ';'
			}
			var str2 = arr2.substr(0, arr2.length - 1)
			this.ruleForm.legalIDImg = str2.substring(str2.lastIndexOf("/") + 1)

			var imgurls3 = this.$refs.uploadChang3.fileList
			var arr3 = ""
			for (var i = 0; i < imgurls3.length; i++) {
				if (imgurls3[i].status != "success") {
					formdata.append("files", imgurls3[i].raw)
				}
				arr3 += imgurls3[i].name + ';'
			}
			var str3 = arr3.substr(0, arr3.length - 1)
			this.ruleForm.operateImg = str3.substring(str3.lastIndexOf("/") + 1)


			var imgurls4 = this.$refs.uploadChang4.fileList
			var arr4 = ""
			for (var i = 0; i < imgurls4.length; i++) {
				if (imgurls4[i].status != "success") {
					formdata.append("files", imgurls4[i].raw)
				}
				arr4 += imgurls4[i].name + ';'
			}
			var str4 = arr4.substr(0, arr4.length - 1)
			this.ruleForm.operateIDImg = str4.substring(str4.lastIndexOf("/") + 1)

			if (this.ruleForm.files1 != "" && this.ruleForm.files1 != null && this.ruleForm.files1 != undefined) {
				formdata.append("files", this.ruleForm.files1)
			}
			if (this.ruleForm.files2 != "" && this.ruleForm.files2 != null && this.ruleForm.files2 != undefined) {
				formdata.append("files", this.ruleForm.files2)
			}
			if (this.ruleForm.files3 != "" && this.ruleForm.files3 != null && this.ruleForm.files3 != undefined) {
				formdata.append("files", this.ruleForm.files3)
			}

			for (let i = 0; i < this.ruleForm.materialList.length; i++) {
				if (this.ruleForm.materialList[i].files != "" && this.ruleForm.materialList[i].files != null && this.ruleForm.materialList[i].files != undefined) {
					formdata.append("files", this.ruleForm.materialList[i].files)
				}
			}
			this.ruleForm.user = JSON.stringify(this.user)
			this.ruleForm.materials = JSON.stringify(this.ruleForm.materialList)
			for (var a in this.ruleForm) {
				if (this.ruleForm[a] == null || this.ruleForm[a] == "null") {
					this.ruleForm[a] = ""
					formdata.append(a, '')
				} else {
					formdata.append(a, this.ruleForm[a])
				}
			}

			company_update(formdata).then((res) => {
				this.$notify({
					title: '提示',
					message: '保存成功',
					type: 'success'
				});
				// this.init()
				this.$router.push({
					path: '/companys'
				})
                this.$store.commit('setlogoimg', res.data.logoImg)
                window.location.reload()
			})
		},
		//判定操作按钮显示
		judgmentAuthority() {
			var type = JSON.parse(localStorage.getItem('panduanzhuangtai'));
			type.map((item1) => {
				if (item1.name == '企业设置' && item1.children != null) {
					for (var i = 0; i < item1.children.length; i++) {
						if (item1.children[i].name === '编辑') this.added = false;
					}
				}
			});
		}
	}
}
</script>

<style scoped>
.avatar-uploader .el-upload {
	border: 1px dashed #d9d9d9;
	border-radius: 6px;
	cursor: pointer;
	position: relative;
	width: 180px;
	overflow: hidden;
}

.avatar-uploader .el-upload:hover {
	border-color: #409EFF;
}

.el-upload--text {
	width: 180px;
}

.avatar-uploader-icon {
	font-size: 28px;
	color: #8c939d;
	width: 178px;
	height: 178px;
	line-height: 178px;
	text-align: center;
}

.avatar {
	width: 178px;
	height: 178px;
	display: block;
}
</style>
